const app = getApp();
Component({
	externalClasses: ['style-class'],
	properties : {
		opentType : {
			type : String,
			value : 'navigate'
		},
		url : {
			type : String,
			value : ''
		},
		default : {
			type : String,
			value : ''
		},
		diystyle : {
			type : String,
			value : ''
		}
	},
	data : {
		_openType : ''
	},
	attached (){
		let that = this;
		let array = ['navigate', 'redirect', 'switchTab', 'reLaunch', 'navigateBack'];

		let tabBar = app.globalData._tabBar.list || [],
			tabBarLists = [],
			_url = that.data.url,
			opentType = that.data.opentType;

		if(array.indexOf(opentType) < 0){
			console.error('路由没有该方法');
			return false;
		}

		for(let i in tabBar){
			let tabUrl = '/' + tabBar[i].pagePath;
			//console.log(tabUrl.indexOf(_url), tabUrl,)
			if(tabUrl.indexOf(_url) >= 0){
				opentType = 'switchTab';
				break;
			}
		}

		that.setData({
			_openType : opentType
		})
	}
})